package web.refer;

import cn.hutool.core.util.StrUtil;

/**
 * @version 1.0.0
 * Created by cyd on 2023-08-11 15:45:11
 * @ClassName : web.refer.TestRefer
 * @Description : 类描述
 */
public class TestRefer {
    public static void main(String[] args) {
//        String host="aiot.eshore.cn";
//        String referer="https://aiot.eshore.cn:8300/smartfire/yax/";
        String host="localhost";
        String referer="http://localhost:8080/";
        String whiteList="localhost,ctwing.cn,eshore.cn,192.168.200.21,172.20.154.24";

        // 首先判断请求域名和referer域名是否相同
        if (referer.contains(host)) {
            if (StrUtil.isEmpty(whiteList)) {
                whiteList = "";
            }
            String[] whiteLists = whiteList.split(",");
            for (String whiteUrl : whiteLists) {
                // 在白名单中的允许
                if (referer.contains(whiteUrl)) {
                    System.out.println("true");
                }
            }
        }
    }
}
